package com.boatAnchorAssistant.service.repository.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.boatAnchorAssistant.pojo.entity.AlarmPushLog;
import com.boatAnchorAssistant.service.mapper.AlarmPushLogMapper;
import com.boatAnchorAssistant.service.repository.in.AlarmPushLogRepository;
import nirvana.core.repository.Repository;
import org.springframework.stereotype.Service;
import com.boatAnchorAssistant.pojo.dto.alarmPushLog.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@Service
public class AlarmPushLogRepositoryImpl extends Repository<AlarmPushLogMapper, AlarmPushLog> implements AlarmPushLogRepository {

    private final AlarmPushLogMapper mapper;

    public AlarmPushLogRepositoryImpl(AlarmPushLogMapper mapper) {
        this.mapper = mapper;
    }

    /**
     * 搜索报警推送日志
     *
     * @param dto
     * @return
     */
    @Override
    public Page<AlarmPushLog> selectAlarmPushLog(SelectAlarmPushLogDto dto) {

        return mapper.selectAlarmPushLog(dto);
    }

    @Override
    public Map<Long, AlarmPushLog> getMap(List<Long> ids) {
        Map<Long, AlarmPushLog> map = new HashMap<>();

        if (CollectionUtil.isNotEmpty(ids)) {
            List<AlarmPushLog> list = listByIds(ids);
            if (CollectionUtil.isNotEmpty(list)) {
                map = list.stream().collect(Collectors.toMap(AlarmPushLog::getId, pojo -> pojo));
            }
        }
        return map;
    }
}